package com.jkc.xh.adapters.viewholder;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jkc.xh.R;
import com.jkc.xh.models.MoneyBillModel;
import com.jkc.xh.utils.Tool;

import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

/**
 * Created by wangjie28 on 2015/11/13.
 */
@EViewGroup(R.layout.item_money_bill)
public class MoneyBillItemView extends RelativeLayout {
    @ViewById(R.id.pay_money)
    TextView pay_money;

    @ViewById(R.id.bal_money)
    TextView bal_money;

    @ViewById(R.id.bill_info)
    TextView bill_info;
    @ViewById
    TextView stock_name;

    @ViewById(R.id.bean_money)
    TextView bean_money;

    @ViewById(R.id.dpt_money)
    TextView dpt_money;

    @ViewById(R.id.fee_money)
    TextView fee_money;

    @ViewById(R.id.create_time)
    TextView create_time;
    @ViewById(R.id.itemTypeIcon)
    ImageView itemTypeIcon;

    public MoneyBillItemView(Context context) {
        super(context);
    }

    public MoneyBillItemView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }


    public void bind(MoneyBillModel model) {
        pay_money.setText(model.pay_money);
        bal_money.setText(model.bal_money);
        bill_info.setText(model.remark);
        bean_money.setText(model.bean_money);
        dpt_money.setText(model.dpt_money);
        fee_money.setText(model.fee_money);
        create_time.setText(Tool.formatSecondSimpleFullDate(model.create_time));
        if(!TextUtils.isEmpty(model.stock_name)){
            stock_name.setText(getResources().getString(R.string.str_stock_name,model.stock_name));
            stock_name.setVisibility(View.VISIBLE);
        }else{
            stock_name.setVisibility(View.GONE);
        }

        if (model.is_in == 1) {
            itemTypeIcon.setImageResource(R.drawable.icon_bill_ru);
            pay_money.setTextColor(getResources().getColor(R.color.text_color_red));
        } else {
            itemTypeIcon.setImageResource(R.drawable.icon_bill_chu);
            pay_money.setTextColor(getResources().getColor(R.color.text_color_blue));
        }

    }

}
